﻿using System;
using System.Collections.Generic;
using System.Dynamic;

namespace IsType测试
{
    class Program
    {
        static void Main(string[] args)
        {

            TypeTest<IBase>();
            TypeTest<A>();
            TypeTest<B>();

            var method = typeof(Program).GetMethod("TypeTest");
            var invoker = (Action)method.CreateDelegate(typeof(Action),typeof(A));
            invoker.Invoke();


            Console.WriteLine("Hello World!");

        }

       
    }

    public class TestTypeMethod
    {
         void TypeTest<T>() where T : class, IBase
        {
            //var t = default(T);
            //    var type = typeof(T);
            //    Console.WriteLine($"{type.FullName} == IBase=={type == typeof(IBase)}");
            //    Console.WriteLine($"{type.FullName} is IBase=={typeof(T) is IBase}");
            //    Console.WriteLine($"{type.FullName} is IBase=={t is IBase}");
            //    Console.WriteLine($"{type.FullName} is IBase=={t is typeof(IBase)}");

            //object instalce = null;
            //try
            //{
            //    //instalce = new T();

            //    // Console.WriteLine($"{type.FullName} 对is IBase=={instalce is IBase}");
            //}
            //catch (Exception ex)
            //{

            //}

            Console.WriteLine("__________________________________________________________");


            //if (instalce is IBase ibase)
            //{
            //    ibase.Say();
            //}

        }
    }

    public abstract class BaseLocation
    {
        public override string ToString()
        {
            return "BaseLocation";
        }
    }

    public class HospitalLocation : BaseLocation
    {
        public override string ToString()
        {
            return "HospitalLocation";
        }
    }

    public class StreetLocation : BaseLocation
    {
        public override string ToString()
        {
            return "StreetLocation";
        }
    }

    public class IndexDetail<T> where T : BaseLocation
    {

    }

    public interface IHandle<T> where T : BaseLocation,new()
    {
        List<T> Say(IndexDetail<T> location);
    }

    public interface IServiceDscript<T> where T : BaseLocation
    {

    }

    public interface IDescriptor<T> where T : BaseLocation
    {
        public IServiceDscript<T> GetDescriptor();
    }




    public class HospitalHandle :IHandle<HospitalLocation>
    {
        private readonly IDescriptor<HospitalLocation> _hosDescriptor;

        public HospitalHandle(IDescriptor<HospitalLocation> hosDescriptor)
        {
            _hosDescriptor = hosDescriptor;
        }

        public List<HospitalLocation> Say(IndexDetail<HospitalLocation> location)
        {
            var servciceDescipotr = _hosDescriptor.GetDescriptor();

            throw new NotImplementedException();
        }
    }
   
}
